import request from '@/utils/request'

const {
  get: $get,
  post: $post,
  // putJson: $put,
  delete: $delete,
  download: $download
} = request

// 生成表分页查询
export const genTablePage = data => {
  return $get('generator/genTable/page', data)
}

// 获取数据源信息
export const getDataSource= data =>{
  return $get('generator/genTable/dataSources', data)
}

// 查询数据库列表
export const genTableDbList = data => {
  return $get('generator/genTable/db/list', data)
}

// 导入生成表
export const importTable = (tables,dbName) => {
  return $post('generator/genTable/importTable/' + tables+"/"+dbName)
}

// 生成表详情
export const genTableDetail = tableId =>{
  return $get('generator/genTable/detail/'+ tableId)
}

// 生成表修改
export const genTableUpdate = data =>{
  return $post('generator/genTable/update',data)
}

// 删除生成表
export const genTableDelete = tableIds =>{
  return $post('generator/genTable/delete/'+tableIds)
}

// 预览代码
export const genTablePreview =tableId =>{
  return $get('generator/genTable/preview/'+tableId)
}

// (批量)生成代码（下载方式）
export const downloadCodeZip = (tableNames,fileName) =>{
  return $download('generator/genTable/download/'+ tableNames,{},fileName)
}

// 生成代码（自定义）
export const customCode = tableName =>{
  return $post('generator/genTable/genCode/'+ tableName)
}

// 同步数据库
export const syncDb = tableName =>{
  return $post('generator/genTable/syncDb/'+ tableName)
}
